import { Dictionary } from "../../Common/Dictionary";
import ADQ from "../../Core/ADQ";
import { IRoleProperty } from "../../Interfaces/IRole";
import { IDictionary } from "../../Interfaces/IUtils";

/**
 * 角色属性
 */
export class RoleProperty implements IRoleProperty {
  protected attrList: IDictionary<number, number>;

  constructor() {
    this.attrList = new Dictionary<number, number>();
  }
  getAttr(type: number): number {
    if (this.attrList.containsKey(type)) return this.attrList.get(type);
    console.debug("can not find propery: " + type);
    return 0;
  }
  changeProperty(type: number, delta: number) {
    var old: number = this.getAttr(type);
    var after: number = old + delta;
    this.setAttr(type, after);
  }
  setAttr(type: number, value: number) {
    this.attrList.set(type, value);
  }
  clear() {
    this.attrList.clear();
  }
  reset() {
    for (let i = 0; i < this.attrList.count; i++) {
      this.attrList[i] = 0;
    }
  }
}
